<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Bom添加</title>
    <link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="css/reset.css">
    <!-- Bootstrap -->
    <link href="css/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet" href="https://at.alicdn.com/t/font_711817_dt555qoeeol.css">
    <link rel="stylesheet" href="css/common.css">
    <!-- HTML5 shim 和 Respond.js 是为了让 IE8 支持 HTML5 元素和媒体查询（media queries）功能 -->
    <!-- 警告：通过 file:// 协议（就是直接将 html 页面拖拽到浏览器中）访问页面时 Respond.js 不起作用 -->
    <!--[if lt IE 9]>
      <script src="https://cdn.bootcss.com/html5shiv/3.7.3/html5shiv.min.js"></script>
      <script src="https://cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
    <style type="text/css">
    .right_content .panel-body {
        padding: 3%;
    }

    table {
        margin-top: 30px;
    }

    thead>tr>th {
        text-align: center;
    }

    .modal-dialog {
        max-height: 600px;
        overflow-y: scroll;
    }

    .modal-dialog::-webkit-scrollbar {
        width: 10px;
    }

    .modal-dialog::-webkit-scrollbar-track {
        -webkit-box-shadow: inset 0 0 6px rgba(0, 0, 0, .3);
        /*  background-color: #337ab7; */
        border-radius: 3px;
    }
    /*定义滑块颜色、内阴影及圆角*/

    .modal-dialog::-webkit-scrollbar-thumb {
        border-radius: 7px;
        -webkit-box-shadow: inset 0 0 6px rgba(0, 0, 0, .3);
        background-color: #E8E8E8;
    }
    /*定义两端按钮的样式*/
    /* .modal-dialog::-webkit-scrollbar-button {
         background-color:#eee;
           } */

    .modal-body table tr td {
        position: relative;
    }

    td>.hide_option {
        position: absolute;
        left: 8px;
        top: 40px;
        width: 181px;
        border: 1px solid #ccc;
        z-index: 66;
        background: #f9f9f9;
        border-top: none;
        display: none;
    }

    td>.hide_option>li {
        width: 100%;
        height: 34px;
        box-sizing: border-box;
        line-height: 22px;
        cursor: pointer;
        padding: 6px 12px;
    }

    td>.hide_option>li:hover {
        background: #eee;
    }

    .close {
        outline: none;
    }
    </style>
</head>

<body>
    <!-- 头部导航 -->
    <nav class="navbar navbar-default navbar-fixed-top">
        <div class="container-fluid">
            <!-- Brand and toggle get grouped for better mobile display -->
            <div class="navbar-header">
                <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
                    <span class="sr-only">Toggle navigation</span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
                <a class="navbar-brand" href="#">
                    <img alt="Brand" src="img/logo.png" class="img-responsive logo">
                    <span>仓库管理系统</span>
                </a>
            </div>
            <!-- Collect the nav links, forms, and other content for toggling -->
            <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
                <ul class="nav navbar-nav navbar-right">
                    <li>
                        <a href="index.html">
                            <i class="icon iconfont">&#xea5b;</i>
                            <span>欢迎</span>
                        </a>
                    </li>
                    <li class="dropdown">
                        <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">用户名 admin
                            <span class="caret"></span>
                        </a>
                        <ul class="dropdown-menu">
                            <li>
                                <a href="#">个人资料</a>
                            </li>
                            <li>
                                <a href="#">Something else here</a>
                            </li>
                            <li role="separator" class="divider"></li>
                            <li>
                                <a href="#">退出登录</a>
                            </li>
                        </ul>
                    </li>
                </ul>
            </div>
            <!-- /.navbar-collapse -->
        </div>
        <!-- /.container-fluid -->
    </nav>
    <!-- 主体部分 -->
    <div class="main">
        <div class="row main_content">
            <!-- 左侧菜单 -->
            <div class="col-xs-4 col-md-2 left_menu">
                <div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
                    <div class="panel panel-default menu_item">
                        <div class="panel-heading" role="tab" id="headingOne">
                            <h4 class="panel-title ">
                                <a class="menu_link clearfix" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseOne" aria-expanded="true" aria-controls="collapseOne">
                                    <span class="menu_title pull-left">库存管理</span>
                                    <span class="caret pull-right"></span>
                                </a>
                            </h4>
                        </div>
                        <div id="collapseOne" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingOne">
                            <div class="panel-body">
                                <div class="list-group">
                                    <a href="#" class="list-group-item">
                                        库存管理
                                    </a>
                                    <a href="#" class="list-group-item">库存管理</a>
                                    <a href="#" class="list-group-item">库存管理</a>
                                    <a href="#" class="list-group-item">库存管理</a>
                                    <a href="#" class="list-group-item">库存管理</a>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="panel panel-default menu_item">
                        <div class="panel-heading" role="tab" id="headingTwo">
                            <h4 class="panel-title">
                                <a class="collapsed menu_link clearfix" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseTwo" aria-expanded="false"
                                    aria-controls="collapseTwo">
                                    <span class="menu_title pull-left">仓库管理</span>
                                    <span class="caret pull-right"></span>
                                </a>
                            </h4>
                        </div>
                        <div id="collapseTwo" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingTwo">
                            <div class="panel-body">
                                <div class="list-group">
                                    <a href="#" class="list-group-item">
                                        货物入库
                                    </a>
                                    <a href="#" class="list-group-item">货物入库</a>
                                    <a href="#" class="list-group-item">货物入库</a>
                                    <a href="#" class="list-group-item">货物入库</a>
                                    <a href="#" class="list-group-item">货物入库</a>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="panel panel-default menu_item">
                        <div class="panel-heading" role="tab" id="headingThree">
                            <h4 class="panel-title">
                                <a class="collapsed menu_link clearfix" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseThree" aria-expanded="false"
                                    aria-controls="collapseThree">
                                    <span class="menu_title pull-left">权限管理</span>
                                    <span class="caret pull-right"></span>
                                </a>
                            </h4>
                        </div>
                        <div id="collapseThree" class="panel-collapse collapse " role="tabpanel" aria-labelledby="headingThree">
                            <div class="panel-body">
                                <div class="list-group">
                                    <a href="#" class="list-group-item">
                                        人员管理
                                    </a>
                                    <a href="#" class="list-group-item">人员管理</a>
                                    <a href="#" class="list-group-item">人员管理</a>
                                    <a href="#" class="list-group-item">人员管理</a>
                                    <a href="#" class="list-group-item">人员管理</a>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="panel panel-default menu_item">
                        <div class="panel-heading" role="tab" id="headingFour">
                            <h4 class="panel-title ">
                                <a class="menu_link clearfix" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseFour" aria-expanded="true" aria-controls="collapseFour">
                                    <span class="menu_title pull-left">基础数据</span>
                                    <span class="caret pull-right"></span>
                                </a>
                            </h4>
                        </div>
                        <div id="collapseFour" class="panel-collapse collapse " role="tabpanel" aria-labelledby="headingFour">
                            <div class="panel-body">
                                <div class="list-group">
                                    <a href="#" class="list-group-item">
                                        供应商信息管理
                                    </a>
                                    <a href="#" class="list-group-item">客户信息管理</a>
                                    <a href="#" class="list-group-item">货物信息管理</a>
                                    <a href="#" class="list-group-item">仓库信息管理</a>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="panel panel-default menu_item">
                        <div class="panel-heading" role="tab" id="headingFive">
                            <h4 class="panel-title ">
                                <a class="menu_link clearfix" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseFive" aria-expanded="true" aria-controls="collapseFive">
                                    <span class="menu_title pull-left">人员管理</span>
                                    <span class="caret pull-right"></span>
                                </a>
                            </h4>
                        </div>
                        <div id="collapseFive" class="panel-collapse collapse " role="tabpanel" aria-labelledby="headingFive">
                            <div class="panel-body">
                                <div class="list-group">
                                    <a href="#" class="list-group-item">
                                        仓库管理员管理
                                    </a>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="panel panel-default menu_item">
                        <div class="panel-heading" role="tab" id="headingSix">
                            <h4 class="panel-title ">
                                <a class="menu_link clearfix" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseSix" aria-expanded="true" aria-controls="collapseSix">
                                    <span class="menu_title pull-left">系统维护</span>
                                    <span class="caret pull-right"></span>
                                </a>
                            </h4>
                        </div>
                        <div id="collapseSix" class="panel-collapse collapse " role="tabpanel" aria-labelledby="headingSix">
                            <div class="panel-body">
                                <div class="list-group">
                                    <a href="#" class="list-group-item">
                                        更改密码
                                    </a>
                                    <a href="#" class="list-group-item">系统日志</a>
                                    <a href="#" class="list-group-item">系统维护</a>
                                    <a href="#" class="list-group-item">系统维护</a>
                                    <a href="#" class="list-group-item">系统维护</a>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <!-- 右侧内容 -->
            <div class="col-xs-8 col-md-10 right_content">
                <div class="panel panel-default">
                    <div class="panel-heading">
                        <ol class="breadcrumb">
                            <li>Bom添加</li>
                        </ol>
                    </div>
                    <div class="panel-body">
                        <form class="form-inline">
                            <div class="form-group">
                                <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#myModal">
                                    <i class="icon iconfont">&#xe669;</i> Bom添加
                                </button>
                            </div>
                        </form>
                        <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
                            <div class="modal-dialog modal-lg" role="document">
                                <div class="modal-content">
                                    <div class="modal-header">
                                        <button type="button" class="close" data-dismiss="modal" aria-label="Close" onClick="clearModal()"><span aria-hidden="true">&times;</span></button>
                                        <h4 class="modal-title" id="myModalLabel">Bom添加</h4>
                                    </div>
                                    <div class="modal-body">
                                        <button class="btn btn-default add_bom">添加</button>
                                        <div class="table-responsive" style="min-height: 300px;">
                                            <table class="table table-bordered text-center table-hover table-striped">
                                                <thead>
                                                    <th>名称</th>
                                                    <th>数量(g)</th>
                                                    <th>单价(元)</th>
                                                    <th>金额(元)</th>
                                                    <th>操作</th>
                                                </thead>
                                                <tbody class="modal_table">
                                                </tbody>
                                            </table>
                                        </div>
                                    </div>
                                    <div class="modal-footer">
                                        <button type="button" class="btn btn-default" data-dismiss="modal" onClick="clearModal()">关闭</button>
                                        <button type="button" class="btn btn-primary">保存</button>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="table-responsive">
                            <table class="table table-bordered text-center table-hover table-striped">
                                <thead>
                                    <th>ID</th>
                                    <th>账号</th>
                                    <th>管理组</th>
                                    <th>登陆次数</th>
                                    <th>上次登陆次数</th>
                                    <th>上次登陆IP</th>
                                    <th>操作</th>
                                </thead>
                                <tbody>
                                    <tr>
                                        <td>1</td>
                                        <td>admin</td>
                                        <td>[系统管理员]</td>
                                        <td>1072</td>
                                        <td>2018-06-21</td>
                                        <td>172.0.0.1</td>
                                        <td>
                                            <a href="#" class="btn btn-info btn-sm">编辑</a>
                                            <button class="btn btn-danger btn-sm">删除</button>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>1</td>
                                        <td>admin</td>
                                        <td>[系统管理员]</td>
                                        <td>1072</td>
                                        <td>2018-06-21</td>
                                        <td>172.0.0.1</td>
                                        <td>
                                            <a href="#" class="btn btn-info btn-sm">编辑</a>
                                            <button class="btn btn-danger btn-sm">删除</button>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>1</td>
                                        <td>admin</td>
                                        <td>[系统管理员]</td>
                                        <td>1072</td>
                                        <td>2018-06-21</td>
                                        <td>172.0.0.1</td>
                                        <td>
                                            <a href="#" class="btn btn-info btn-sm">编辑</a>
                                            <button class="btn btn-danger btn-sm">删除</button>
                                        </td>
                                    </tr>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!-- jQuery (Bootstrap 的所有 JavaScript 插件都依赖 jQuery，所以必须放在前边) -->
    <script src="js/jquery-1.10.2.min.js"></script>
    <!-- 加载 Bootstrap 的所有 JavaScript 插件。你也可以根据需要只加载单个插件。 -->
    <script src="js/bootstrap.min.js"></script>
    <script type="text/javascript">
    //onfocus="showNext(this)"
    $(function() {
        var key = 0;
        $(".add_bom").click(function() {
            var html = '<tr id="' + key + '"><td><input type="text" class="form-control match" onKeyup="getContent(this)"><ul class="hide_option"></ul></td><td><input type="text" class="form-control"></td><td><input readonly type="text" class="form-control"></td><td><input type="text" readonly class="form-control"></td><td><button onclick="del(' + key + ')" class="btn btn-sm btn-danger">删除</button></tr>';
            $(".modal_table").append(html);
            key++;
        })
    })

    function getContent(obj) {
        var data = ["111", "12", "222", "333"];
        var kw = jQuery.trim($(obj).val());
        if (kw == "") {
            $(obj).next().hide().html("");
            return false;
        }
        var html = "";
        for (var i = 0; i < data.length; i++) {
            if (data[i].indexOf(kw) >= 0) {
                html = html + "<li  onClick='getCon(this);'>" + data[i] + "</li>"
            }
        }
        if (html != "") {
            $(obj).next().show().html(html);
        } else {
            $(obj).next().hide().html("");
        }
    }

    function showNext(obj) {
        $(obj).next().css("display", "block")
    }

    function hideNext(obj) {
        $(obj).next().css("display", "none")
    }

    function getCon(obj) {
        var value = $(obj).text();
        $(obj).parent().prev(".match").val(value);
        $(obj).parent().hide()
    }

    function del(id) {
        $('#' + id).remove();
    }

    function clearModal() {
        $('.modal_table').html("")
    }
    </script>
    <script type="text/javascript">
    /*$(function() {
        var key = 0;
        $(".add_bom").click(function() {
            var html = '<tr id="' + key + '"><td><input type="text" id="title' + key + '" name="title' + key + '" data="' + key + '" class="form-control match" onKeyup="getContent(this)"><ul class="hide_option"></ul></td><td><input onKeyup="getNum(this)" id="num' + key + '" name="num' + key + '" type="number" data-key="' + key + '" class="form-control"></td><td><input name="unit_price' + key + '" id="unit_price' + key + '" readonly type="text" class="form-control"></td><td><input id="total' + key + '" name="total' + key + '" type="text" readonly class="form-control"></td><td><button onclick="del(' + key + ')" class="btn btn-sm btn-danger">删除</button><input type="hidden"  id="price' + key + '"></tr>';
            $(".modal_table").append(html);
            key++;
        })
    });

    function getContent(obj) {
        $.ajax({
            url: '/admin/goods/ajaxBom',
            success: function(data) {
                var kw = jQuery.trim($(obj).val());
                if (kw == "") {
                    $(obj).next().hide().html("");
                    return false;
                }
                var html = "";
                for (var i = 0; i < data.length; i++) {
                    if (data[i].title.indexOf(kw) >= 0) {
                        html = html + "<li onClick='getCon(this)' data-unit_price = " + data[i].unit_price + ">" + data[i].title + "</li>";
                    }
                }
                if (html != "") {
                    $(obj).next().show().html(html);
                } else {
                    $(obj).next().hide().html("");
                }
            }
        });
    }

    function showNext(obj) {
        $(obj).next().css("display", "block")
    }

    function hideNext(obj) {
        $(obj).next().css("display", "none")
    }

    function total(num, price) {
        var total = 0;
        total = (num * price) / 1000;
        return total;
    }

    function getNum(obj) {
        var num = $(obj).val();
        var key = $(obj).attr("data-key");
        var price = $('#price' + key).val();
        $('#total' + key).val(total(num, price));
    }

    function getCon(obj) {
        var value = $(obj).text();
        var unit_price = $(obj).attr('data-unit_price');
        $(obj).parent().prev(".match").val(value);
        var key = $(obj).parent().prev(".match").attr('data');
        $('#unit_price' + key).val(unit_price);
        $('#price' + key).val(unit_price);
        // $('title'+key).val(data.title);
        $(obj).parent().hide()
    }

    function del(id) {
        $('#' + id).remove();
    }

    function clearModal() {
        $('.modal_table').html("")
    }

    function refer(event) {
        event.stopPropagation();
    }*/
    </script>
</body>

</html>